/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

/*密码应为8-20位，且同时包含字母，数字，特殊字符。（特殊字符从_、*、/、#、@ 五种中至少选择一种）*/
export function validPassWord(path) {
  return /^(?![a-zA-Z]+$)(?![0-9]+$)(?![*_/#@]+$)(?![a-zA-Z0-9]+$)(?![a-zA-Z*_/#@]+$)(?![0-9*_/#@]+$)[a-zA-Z0-9*_/#@]{8,20}$/.test(path)
}

/*校验身份证*/
export function validReg() {
  return{
    emailReg:/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
    letterReg:/^[a-z]+$/i,
    numberReg:/^\d+$/,
    phoneReg:/^1\d{10}$/,
    numReg:/^\d+$/,
    entContactReg:/^\d+(-\d+)*$/,
    chineseReg:/[\u4e00-\u9fa5]/gm,
    taxIdReg:/^[a-z0-9]+$/i,
    nameReg:/[\u4e00-\u9fa5]/gm,
    cardNoReg:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  }
}
